<%@page import="com.mysql.jdbc.StringUtils"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String type1 = request.getParameter("type");
	String type2 = (String) request.getAttribute("type");
// 	System.out.println(con);
	String type = type1 == null ? type2 : type1;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<%=basePath%>css/bootstrap.css" rel="stylesheet">
<link href="<%=basePath%>css/common.css" rel="stylesheet">
<!-- <link href="<%=basePath%>css/home.css" rel="stylesheet"> -->
<link href="<%=basePath%>css/pagination.css" rel="stylesheet">
<link href="<%=basePath%>css/index.css" rel="stylesheet">
<link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet"
	media="screen">
<link href="<%=basePath%>css/bootstrap-responsive.css" rel="stylesheet">

<link type="text/css" href="<%=basePath%>css/main_search.css"
	rel="stylesheet">

<script type="text/javascript" src="<%=basePath%>js/jquery.js"></script>
<!-- <script type="text/javascript" src="<%=basePath%>js/bootstrap.min.js"></script> -->
<!-- <script src="<%=basePath%>js/jsonp.js" type="text/javascript"></script> -->
<!-- <script src="<%=basePath%>js/ser_person.js" type="text/javascript"></script> -->
<link href="<%=basePath%>css/ask_float_block.css" type="text/css"
		rel="stylesheet" />
<script type='text/javascript'>
(function(){
$(function(){
	var back_top_value =Math.ceil(document.documentElement.clientHeight *0.65);
	var float_ask_img="<div data-mod='popu_64' class='tracking-ad' chg-blk='0' ><a id='com-d-top-a'  style='top:"+back_top_value+"px' title='返回顶部' onclick='' ></a> </div>";
	$("body").append(float_ask_img);
	
	var d_top = $('#com-d-top-a');

        $(document).scroll(function(){
            var scrTop = (document.body.scrollTop || document.documentElement.scrollTop);
            if (scrTop > 500)
            {
                d_top.show();
            } else
            {
                d_top.hide();
            }

        })
        $('#com-d-top-a').click(function ()
        {
            scrollTo(0, 0);
            this.blur();
            return false;
        });
});
})();
</script>




<script type="text/javascript">
	$(document).ready(function() {
		$("ul li").click(function() {

			var ili = $(".search-type")[0].children.length;
			for ( var i = 0; i < ili; i++) {
				$(".search-type")[0].children[i].style.color = "#000000";
			}

			if (this.innerHTML == "博文") {
				$("#tt")[0].value = "1";
				$(".search-type")[0].children[0].style.color = "#990000";
			} else if (this.innerHTML == "帖子") {
				$("#tt")[0].value = "2";
				$(".search-type")[0].children[1].style.color = "#990000";
			} else if (this.innerHTML == "资源") {
				$("#tt")[0].value = "3";
				$(".search-type")[0].children[2].style.color = "#990000";
			} else if (this.innerHTML == "问答") {
				$("#tt")[0].value = "4";
				$(".search-type")[0].children[3].style.color = "#990000";
			}
			if(judge()){
				document.search_form_1.submit();
			}else{
				$("#result_list").hide();
				$("#result_page").hide();
			}
		});
	});
</script>

<script language="JavaScript" type="text/JavaScript">
	$(document).ready(function() {
		
		var ili = $(".search-type")[0].children.length;
		for ( var i = 0; i < ili; i++) {
			$(".search-type")[0].children[i].style.color = "#000000";
		}
		var t = '<%=type%>';
		if (t == "1") {
			$(".search-type")[0].children[0].style.color = "#990000";
		} else if (t == "2") {
			$(".search-type")[0].children[1].style.color = "#990000";
		} else if (t == "3") {
			$(".search-type")[0].children[2].style.color = "#990000";
		} else if (t == "4") {
			$(".search-type")[0].children[3].style.color = "#990000";
		}
			$("#q1").keyup(function() {
				if (event.keyCode == 13) {
					if (judge()) {
						$("#search_form_1").submit();
					}
				}
			});

	});
</script>
<style type="text/css">
.page_nav {
	TEXT-ALIGN: center;
	PADDING-BOTTOM: 15px;
	PADDING-LEFT: 0px;
	PADDING-RIGHT: 0px;
	FONT: 12px/24px Arial;
	COLOR: #666;
	CLEAR: both;
	PADDING-TOP: 15px
}

.page_nav A {
	BORDER-BOTTOM: #dbe5ee 1px solid;
	BORDER-LEFT: #dbe5ee 1px solid;
	PADDING-BOTTOM: 0px;
	MARGIN: 0px 2px;
	PADDING-LEFT: 8px;
	PADDING-RIGHT: 8px;
	DISPLAY: inline-block;
	FONT: 12px/22px Arial, Helvetica, sans-serif;
	BACKGROUND: #fff;
	HEIGHT: 22px;
	COLOR: #333;
	BORDER-TOP: #dbe5ee 1px solid;
	CURSOR: pointer;
	BORDER-RIGHT: #dbe5ee 1px solid;
	PADDING-TOP: 0px;
	border-radius: 2px;
	-moz-border-radius: 2px;
	-webkit-border-radius: 2px;
	-khtml-border-radius: 2px
}

.page_nav STRONG {
	BORDER-BOTTOM: medium none;
	BORDER-LEFT: medium none;
	PADDING-BOTTOM: 0px;
	LINE-HEIGHT: 24px;
	MARGIN: 0px 3px;
	PADDING-LEFT: 8px;
	PADDING-RIGHT: 8px;
	DISPLAY: inline-block;
	BACKGROUND: #07519a;
	HEIGHT: 24px;
	COLOR: #fff;
	BORDER-TOP: medium none;
	FONT-WEIGHT: normal;
	BORDER-RIGHT: medium none;
	TEXT-DECORATION: none;
	PADDING-TOP: 0px;
	border-radius: 2px;
	-moz-border-radius: 2px;
	-webkit-border-radius: 2px;
	-khtml-border-radius: 2px
}

.page_nav A:hover {
	BORDER-BOTTOM: medium none;
	BORDER-LEFT: medium none;
	LINE-HEIGHT: 24px;
	MARGIN: 0px 3px;
	BACKGROUND: #07519a;
	HEIGHT: 24px;
	COLOR: #fff;
	BORDER-TOP: medium none;
	BORDER-RIGHT: medium none;
	TEXT-DECORATION: none
}

.page_nav A.select {
	CURSOR: default
}
</style>
<script type="text/javascript">
	function judge() {
		if ($("#q1").val().trim()) {
			return true;
		} else {
			return false;
		}
	}
</script>
</head>
<body>

	<div class="topadv"></div>
	<div class="main-container">
		<div class="con-l">
			<ul class="search-type">
				<li>博文</li>
				<li>帖子</li>
				<li>资源</li>
				<li>问答</li>
			</ul>
			<div class="search-from2" style="position:relative">
				<form id="search_form_1" name="search_form_1"
					onsubmit="return judge()" method="post"
					action="<%=basePath%>SearchServlet">
					<div class="search-text-con2">
						<input type="text" class="search-text2" id="q1"
							name="searchc" value="${requestScope.searchc}" /> <input type="hidden" id="tt"
							name="tyle" value="<%=type%>" /> <input type="hidden" id="ot"
							name="pagenow" value="1"/>
						<input type="hidden" id="st" name="s" value="" />
					</div>
					<div class="search-btn-con2">
						<input type="Submit" value="搜一搜" class="search-btn2">
					</div>
				</form>
			</div>


			<div class="add-tag-con" style="display:none"></div>

			<%
				if (!StringUtils.isNullOrEmpty(type2)) {
			%>
			<c:if test="${requestScope.resultPage.count ne 0 }">
			<div class="search-list-con" id="result_list">
				<c:forEach items="${requestScope.resultPage.list}" var="result">
					<dl class="search-list">
						<dt>
							<a
								<c:choose>
								<c:when test="${requestScope.type eq '1' }">
									href="<%=basePath %>learning/article.jsp?blogId=${result.reId}&userId=${result.reEditorId }&blogName=${result.reTitle}"
								</c:when>
								<c:when test="${requestScope.type eq '2' }">
									href="<%=basePath %>community/"
								</c:when>
								<c:when test="${requestScope.type eq '3' }">
									href="<%=basePath %>download/downloadpage.jsp?dataId=${result.reId}"
								</c:when>
								<c:when test="${requestScope.type eq '4' }">
									href="<%=basePath %>questions/questionDetail.jsp?questionId=${result.reId}"
								</c:when>
							</c:choose>
								target="_blank">${result.reTitle} </a>
						</dt>
						<dd class="author-time">
							作者：<a
								<c:choose>
							<c:when test="${requestScope.type eq '1' }">
								href="<%=basePath %>learning/personal.jsp?userId=${result.reEditorId }"
							</c:when>
							<c:when test="${requestScope.type eq '2' }">
								href="<%=basePath %>community/"
							</c:when>
							<c:when test="${requestScope.type eq '3' }">
								href="<%=basePath %>download/"
							</c:when>
							<c:when test="${requestScope.type eq '4' }">
								href="<%=basePath %>questions/"
							</c:when>
						</c:choose>
								target="_blank">${result.reEditor}</a>&nbsp;&nbsp;&nbsp;日期：${result.reCreatOn}&nbsp;&nbsp;&nbsp;
								<c:choose>
									<c:when test="${requestScope.type eq '3' }">
									下载
									</c:when>
									<c:when test="${requestScope.type eq '4' }">
									点赞
									</c:when>
									<c:otherwise>
									浏览
									</c:otherwise>
								</c:choose>
								&nbsp;${result.reHitNum }&nbsp;次
						</dd>
						<!-- 					<dd class="search-detail"> -->
						<!-- 						关于Java <em>Web开发</em>的技术非常多，JSP、Servet、JSF、Struts、Hibernate、WebWork、Spring、Tapestry、JPA等等，关于这些技术的书籍也非常多，有专门讲某种技术的，有若干技术综合在一起的。如果读者要想学习的话，可能需要多本书，这样学习的成本也会比较高。所以我想如果能编写这样一本书就好了，通过这本书的介绍可以对 -->
						<!-- 					</dd> -->
						<dd class="search-link">
							<a
								<c:choose>
								<c:when test="${requestScope.type eq '1' }">
									href="<%=basePath %>learning/article.jsp?blogId=${result.reId}&userId=${result.reEditorId }&blogName=${result.reTitle}"
								</c:when>
								<c:when test="${requestScope.type eq '2' }">
									href="<%=basePath %>community/"
								</c:when>
								<c:when test="${requestScope.type eq '3' }">
									href="<%=basePath %>download/downloadpage.jsp?dataId=${result.reId}"
								</c:when>
								<c:when test="${requestScope.type eq '4' }">
									href="<%=basePath %>questions/questionDetail.jsp?questionId=${result.reId}"
								</c:when>
							</c:choose>
								target="_blank"> <c:choose>
									<c:when test="${requestScope.type eq '1' }">
										<%=basePath%>learning/acticle.jsp?blogId=${result.reId}&userId=${result.reEditorId }&blogName=${result.reTitle}
								</c:when>
									<c:when test="${requestScope.type eq '2' }">
										<%=basePath%>community/
								</c:when>
									<c:when test="${requestScope.type eq '3' }">
										<%=basePath%>download/downloadpage.jsp?dataId=${result.reId}
								</c:when>
									<c:when test="${requestScope.type eq '4' }">
										<%=basePath%>questions/questionDetail.jsp?questionId=${result.reId}
								</c:when>
								</c:choose>
							</a>
						</dd>
					</dl>
				</c:forEach>

			</div>
			</c:if>
			<%
				}
			%>
			<c:if test="${requestScope.resultPage.count>0 }">
				<div class="page_nav" id="result_page">
								<span> ${requestScope.resultPage.count}条数据
									共${requestScope.resultPage.totalPage}页</span>
								<c:if test="${requestScope.resultPage.currentPage>1}">
									<a href="SearchServlet?tyle=<%=type%>&pagenow=1&searchc=${requestScope.searchc}">首页</a>
									<a
										href="SearchServlet?tyle=<%=type%>&pagenow=${requestScope.resultPage.currentPage-1}&searchc=${requestScope.searchc}">上一页</a>
								</c:if>
								<c:if test="${requestScope.resultPage.pageDiffer>0}">
									<a
										href="SearchServlet?tyle=<%=type%>&pagenow=${requestScope.resultPage.pageDiffer*5-4}&searchc=${requestScope.searchc}">...</a>
								</c:if>

								<c:if
									test="${requestScope.resultPage.pageDiffer*5+1<=requestScope.resultPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.resultPage.currentPage==requestScope.resultPage.pageDiffer*5+1 }">
											<strong>${requestScope.resultPage.pageDiffer*5+1}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="SearchServlet?tyle=<%=type%>&pagenow=${requestScope.resultPage.pageDiffer*5+1}&searchc=${requestScope.searchc}">${requestScope.resultPage.pageDiffer*5+1}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.resultPage.pageDiffer*5+2<=requestScope.resultPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.resultPage.currentPage==requestScope.resultPage.pageDiffer*5+2 }">
											<strong>${requestScope.resultPage.pageDiffer*5+2}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="SearchServlet?tyle=<%=type%>&pagenow=${requestScope.resultPage.pageDiffer*5+2}&searchc=${requestScope.searchc}">${requestScope.resultPage.pageDiffer*5+2}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.resultPage.pageDiffer*5+3<=requestScope.resultPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.resultPage.currentPage==requestScope.resultPage.pageDiffer*5+3 }">
											<strong>${requestScope.resultPage.pageDiffer*5+3}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="SearchServlet?tyle=<%=type%>&pagenow=${requestScope.resultPage.pageDiffer*5+3}&searchc=${requestScope.searchc}">${requestScope.resultPage.pageDiffer*5+3}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.resultPage.pageDiffer*5+4<=requestScope.resultPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.resultPage.currentPage==requestScope.resultPage.pageDiffer*5+4 }">
											<strong>${requestScope.resultPage.pageDiffer*5+4}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="SearchServlet?tyle=<%=type%>&pagenow=${requestScope.resultPage.pageDiffer*5+4}&searchc=${requestScope.searchc}">${requestScope.resultPage.pageDiffer*5+4}</a>
										</c:otherwise>
									</c:choose>
								</c:if>

								<c:if
									test="${requestScope.resultPage.pageDiffer*5+5<=requestScope.resultPage.totalPage}">
									<c:choose>
										<c:when
											test="${requestScope.resultPage.currentPage==requestScope.resultPage.pageDiffer*5+5 }">
											<strong>${requestScope.resultPage.pageDiffer*5+5}</strong>
										</c:when>
										<c:otherwise>
											<a
												href="SearchServlet?tyle=<%=type%>&pagenow=${requestScope.resultPage.pageDiffer*5+5}&searchc=${requestScope.searchc}">${requestScope.resultPage.pageDiffer*5+5}</a>
										</c:otherwise>
									</c:choose>
								</c:if>
								<c:if
									test="${requestScope.resultPage.totalPage>5 && requestScope.resultPage.pageDiffer<requestScope.resultPage.totalPage/5-1}">
									<a
										href="SearchServlet?tyle=<%=type%>&pagenow=${requestScope.resultPage.pageDiffer*5+6}&searchc=${requestScope.searchc}">...</a>
								</c:if>
								<c:if
									test="${requestScope.resultPage.currentPage<requestScope.resultPage.totalPage}">
									<a
										href="SearchServlet?tyle=<%=type%>&pagenow=${requestScope.resultPage.currentPage+1}&searchc=${requestScope.searchc}">下一页</a>
									<a
										href="SearchServlet?tyle=<%=type%>&pagenow=${requestScope.resultPage.totalPage}&searchc=${requestScope.searchc}">尾页</a>
								</c:if>
						</div>
			</c:if>
			<c:if test="${requestScope.resultPage.count eq 0}">
			<div>
				<p class="pointout">抱歉，没有找到相关结果。</p>
			</div>
			</c:if>
		</div>
	</div>

</body>

</html>


